package StorageComponents;

import Exceptions.InvalidArrayLengthException;

/**
 * 
 *  This class represents an 8 bit accumulator register
 */
public class Accumulator {

	private int[] acc;
	
	/**
	 * Initialize the accumulator reference
	 */
	public Accumulator(){		
		acc = new int[8];
	}
	
	/**
	 * Returns the accumulator content
	 * @return the accumlator content
	 */
	public int[] get(){
		return acc;
	}
	
	/**
	 * Set a new value on the accumlator
	 * @param data - the value to be stored
	 * @throws InvalidArrayLengthException
	 */
	public void set(int[] data)throws InvalidArrayLengthException{
		if( data.length != 8 )
			throw new InvalidArrayLengthException("Cannot set accumulator. Expected data.length = 8. Received +" +
					"data.length = " + data.length );
		acc = data;

	}
	
}
